package com.summer.springboot.timing.task.quartz.mem;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class QuartzConfig {

    @Bean
    public JobDetail jobDetail() {
        return JobBuilder.newJob(QuartzSimpleTask.class)
                    .withIdentity("QuartzSimpleTask")
                    .storeDurably().build();
    }

    @Bean
    public Trigger taskTrigger() {
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("*/5 * * * * ?");
        return TriggerBuilder.newTrigger().forJob(jobDetail())
                    .withIdentity("QuartzSimpleTask")
                    .withSchedule(scheduleBuilder)
                    .build();
    }
}
